package com.mrzhiyi.demo.sb.common.generate;

import com.baomidou.mybatisplus.generator.FastAutoGenerator;
import com.baomidou.mybatisplus.generator.config.OutputFile;
import com.baomidou.mybatisplus.generator.engine.FreemarkerTemplateEngine;
import java.util.Collections;

/**
 * @author Kevin
 * @since 2024.06.17
 **/
public class CodeGenerator{
    public static void main(String[] args){
        FastAutoGenerator.create("jdbc:mysql://127.0.0.1:63306/briup","root","root")
                         .globalConfig(builder->builder.author("Kevin Liu")
                                                       .outputDir("D:\\document\\desktop\\code")
                                                       .commentDate("yyyy-MM-dd"))
                         .packageConfig(builder->builder.parent("com.mrzhiyi.demo.sb")
                                                        .entity("entity")
                                                        .mapper("mapper")
                                                        .service("service")
                                                        .serviceImpl("service.impl")
                                                        .pathInfo(Collections.singletonMap(OutputFile.xml,"D:\\document\\desktop\\code\\xml")))
                         .strategyConfig(builder->builder.addTablePrefix("s_")
                                                         .entityBuilder()
                                                         .enableFileOverride()
                                                         .enableLombok()
                                                         .enableTableFieldAnnotation()
                                                         .enableChainModel()
                                                         .controllerBuilder()
                                                         .enableFileOverride()
                                                         .enableRestStyle()
                                                         .mapperBuilder()
                                                         .enableFileOverride()
                                                         .serviceBuilder()
                                                         .enableFileOverride())
                         .templateEngine(new FreemarkerTemplateEngine()).execute();
    }
}
